package com.lczyfz.istep.modules.openstack.utils;


import com.lczyfz.istep.modules.openstack.api.keystone.Keystone;

/**
 * ���ڷ�װ�������ÿ�η����������һЩĬ�ϲ���
 * @author jm
 */
public class RequestFactory {
	
	private Keystone keystone;
	
	private String tokenId;
	
	private String host;
	
	public RequestFactory(String serviceName){
		keystone = Keystone.getInstance();
		this.host = keystone.getCatalogService().getEndpoint(serviceName).getUrl();
	}
	
	public Request getRequest(){
		this.tokenId = keystone.getTokenService().login().getId();
		Request request = new Request();
		request.setHost(this.host);
		request.putHeader("X-Auth-Token", this.tokenId);
		request.putHeader("X-Subject-Token", this.tokenId);
		return request;
	}
}
